/**   
 * Copyright © 2016 公司名. All rights reserved.
 * 
 * @Title: PrivateKeyRestController.java 
 * @Prject: LianniuManager
 * @Package: com.lianniu.mgr.privateKey.controller
 * @Description: TODO
 * @author: Administrator   
 * @date: 2016年11月10日 下午4:22:34 
 * @version: V1.0   
 */
package com.lianniu.mgr.privateKey.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lianniu.mgr.base.BaseResult;
import com.lianniu.mgr.baseService.staff.model.StaffVo;
import com.lianniu.mgr.pagination.PaginationInfo;
import com.lianniu.mgr.privateKey.model.PrivateKeyVo;
import com.lianniu.mgr.privateKey.service.IPrivateKeyService;
import com.lianniu.mgr.privateKey.service.IServiceorService;

/** 
 * @ClassName: PrivateKeyRestController 
 * @Description: 秘钥请求controller
 * @author: lzz
 * @date: 2016年11月10日 下午4:22:34  
 */
@Controller
@RequestMapping(value={"rest"})
public class PrivateKeyRestController {
    
    private final static Logger logger = Logger.getLogger(PrivateKeyRestController.class);
    @Autowired
    private IPrivateKeyService privateKeyService;
    
    @Resource
    private IServiceorService serviceorService;
    
    /**
     * @Title: getSimplePrivateKey 
     * @Description: PrivateKeyRestController获取一个或一组邀请码
     * @author: lzz
     * @param userId 用户Id作为添加人ID
     * @param staffId 业务员Id
     * @param staffName 业务员姓名
     * @param staffMobile 业务员电话
     * @date: 2016年11月11日 上午9:06:13 
     * @return: BaseResult
     */
    @RequestMapping(value={"getPrivateKey"})
    @ResponseBody
    public BaseResult getPrivateKey(String userId,String staffId,String staffName,Long staffMobile,int sum){
        logger.info("Controller getPrivateKey begin");
        BaseResult result = null;
        if(sum > 1){
            logger.info("Controller getPrivateKey getQueryPrivateKey begin");
            result = privateKeyService.getQueryPrivateKey(userId, staffId, staffName, staffMobile,sum);
            logger.info("Controller getPrivateKey getQueryPrivateKey end");
        }else{
            logger.info("Controller getPrivateKey getSimplePrivateKey begin");
            result = privateKeyService.getSimplePrivateKey(userId, staffId, staffName, staffMobile);
            logger.info("Controller getPrivateKey getSimplePrivateKey end");
        }
        logger.info("Controller getPrivateKey end");
        return result;
    }
    /**
     * @Title: selectPrivateKey 
     * @Description: 根据业务员ID查看可用的邀请码
     * @author: lzz
     * @param staffId
     * @date: 2016年11月18日 下午12:12:53 
     * @return: BaseResult
     */
    @RequestMapping(value={"selectPrivateKey"})
    @ResponseBody
    public BaseResult selectPrivateKey(String staffId){
        logger.info("Controller selectPrivateKey begin");
            logger.info("Controller selectPrivateKey getQueryPrivateKey begin");
        BaseResult  result = privateKeyService.getQueryPrivateKey(staffId);
            logger.info("Controller selectPrivateKey getQueryPrivateKey end");
        logger.info("Controller selectPrivateKey end");
        return result;
    }
    /**
     * @Title: getPrivateKeyList 
     * @Description: 邀请码列表
     * @author: Administrator
     * @param privateKeyVo
     * @param paginationInfo
     * @date: 2016年11月11日 上午9:14:56 
     * @return: BaseResult
     */
    @RequestMapping(value={"getPrivateKeyList"})
    @ResponseBody
    public BaseResult getPrivateKeyList(PrivateKeyVo privateKeyVo, PaginationInfo paginationInfo){
        logger.info("Controller getPrivateKeyList begin");
        BaseResult result = null;
        logger.info("Controller getPrivateKeyList getListPrivateKey begin");
        result = privateKeyService.getListPrivateKey(privateKeyVo, paginationInfo);
        logger.info("Controller getPrivateKeyList getListPrivateKey end");
        logger.info("Controller getPrivateKeyList end");
        return result;
    }
    @RequestMapping(value={"getServiceorList"},method = RequestMethod.POST)
    @ResponseBody
    public BaseResult getServiceorList(HttpServletRequest request, StaffVo staffVo,
            PaginationInfo paginationInfo){
        logger.info("Controller getPrivateKey begin");
        BaseResult r = serviceorService.getServiceorList(staffVo, paginationInfo);
        logger.info("Controller getPrivateKey end");
        return r;
    }
}
